﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel.Composition;

namespace AppToolkit.WPF.Services.UserMessageHandling.UI
{
    /// <summary>
    /// Interaction logic for MessageView.xaml
    /// </summary>
    [Export]
    public partial class MessageView : UserControl
    {
        IMessageVisualizer _visualizer;

        /// <summary>
        /// CTOR
        /// </summary>
        public MessageView()
        {
            InitializeComponent();
        }

        /// <summary>
        /// ViewModel that holds the state that shall be visualized.
        /// </summary>
        [Import(typeof(IMessageVisualizer))]
        public IMessageVisualizer Visualizer
        {
            set
            {
                _visualizer = value;
                this.DataContext = value;
            }
        }

        private void OnFocusChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            this._visualizer.IsFocused = (bool)e.NewValue;
        }
    }
}
